package pers.liyan.shi.springboot.service;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.stereotype.Service;
import pers.liyan.shi.springboot.bean.Book;

@Service
public class BookService {

    /**
     * 监听RabbitMQ消息队列
     */
    @RabbitListener(queues = "sly")
    public void receiveBook(Book book){
        System.out.println("Received Message...");
        System.out.println(book);
    }

    @RabbitListener(queues = "sly.news")
    public void receiveOriginalMsg(Message message){
        System.out.println(message.getBody());
        System.out.println(message.getMessageProperties());
    }

}
